<?php
	//require_once("./Include.php");
	//require_once("sessionManager.php");
	define('UPLOAD_DIR', '../calques/');
    $img = $_POST['img'];
    $id = $_POST['id'];
    $img = str_replace('data:image/png;base64,', '', $img);
    $img = str_replace(' ', '+', $img);
    $data = base64_decode($img);
    $file = UPLOAD_DIR.$id.'.png';
    $success = file_put_contents($file, $data);
    print $success ? $file : 'Unable to save the file.';
?>